/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package plan.mobile;

import java.util.Iterator;
import mobile.Call;
import mobile.Message;
import mobile.MobileConsumption;
import plan.Plan;
import turnover.Consumption;

/**
 *
 * @author Ale
 */
public class Yoigo_la_del_8 extends Plan {

    private double startQuote = 0d;
    private double minuteNationalCost = 0.08d;
    private double minuteInternationalCost = 0.30d;
    private double messageCost = 0.08d;

    public Yoigo_la_del_8() {
        super.setName("Yoigo la del 8");
    }

    public double getStartQuote() {
        return startQuote;
    }

    @Override
    public double getCost(Consumption consumption) {
        double total = 0d;
        MobileConsumption mc = (MobileConsumption) consumption;
        Iterator it = mc.getCallList().listIterator();
        while (it.hasNext()) {
            Call c = (Call) it.next();
            if (c.isSpecial()) {
                total += c.getCost();
            } else {
                total += c.getDuration().changeSeconds() * this.minuteNationalCost / 60;
            }
        }
        it = mc.getMessList().listIterator();
        while (it.hasNext()) {
            Message m = (Message) it.next();
            if (m.isSpecial()) {
                total += m.getCost();
            } else {
                total += this.messageCost;
            }
        }
        if (total < 6d) {
            total = 6d;
        }
        total += total * 0.16d;
        return total;
    }

    public double getMessageCost() {
        return messageCost;
    }

    public double getMinuteCost() {
        return minuteNationalCost;
    }
}



